#!./perl

# ------------------------------------------------------------

# initdev.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
# This allows the development environment to choose what
# page to load depending on the existence of .cdev

# ------------------------------------------------------------

# Bugs and other fixes

# ------------------------------------------------------------
##############################################################################
# CompressFiles: tar the insertion files and compress them
##############################################################################
sub CompressFiles
{
	$res =  `tar cvf $TARFILE $HomeDir`;
	$res =~ s/\n/<br>/g;
	print $res;
	$res =  `compress $TARFILE; ls -l $TARFILE.Z`;
	$res =~ s/\n/<br>/g;
	print $res;
}

##############################################################################
# main
##############################################################################
$BASEDIR = $ENV{"DOCUMENT_ROOT"};
require 'devinfo.pl';
require 'tools.pl';

if ($ENV{'REQUEST_METHOD'} eq "POST") {
	read(STDIN, $request, $ENV{'CONTENT_LENGTH'});
} elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) {
	$request = $ENV{'QUERY_STRING'};
}

$HomeDir = &GetDevinfo("dir");
$TARFILE = $HomeDir . "/../cdware.tar";

$~ = HEADER;
write;

$request =~ s/%(..)/pack("c",hex($1))/ge;
print "request=$request<br>";
print "ARGV0=$ARGV[0]<br>";
#if (@ARGV == 0 && $request eq "") {


if ($ARGV[0] ne "") {
	&CompressFiles();
	if ($ARGV[0] eq "FTP") {
		print "in case argv=ftp";
	} elsif ($ARGV[0] eq "TAPE") {
		print "in tape<br>";
	} elsif ($ARGV[0] eq "DISKETTE") {
		print "in disk<br>";
		#&CreateDefaultIndex();
	}
} else {
	unless (-s $HomeDir . "/index.html") {
		&PrintErr("NoExist", "$HomeDir/index.html");
	}
	print "<h2>checks the file names</h2>";
}


	#$~ = MIDDLE;
	#write;

	$~ = FOOTER;
	write;


##############################################################################
# formats
##############################################################################
format HEADER =
Content-type: text/html


<html>
<title>Catalyst CDware - Development environment</title>
<body>
<h1>CDware Development environment</h1>
<h4>Currently working with "@*
$HomeDir
"</h4>
<h2>Are you sure you are done with your insertion?</h2>
<ol type=1>
.

format MIDDLE =
<li><a href="http://localhost:7999/cgi-bin/edit_info.pl?HTML">Edit _info(perl)</a><br>
<li><a href="@*"
"file://" . $HomeDir . "/index.html"
>Test your insertion</a>
.

format FOOTER =
</ol>
<p>
<hr>
<p>
You, like these companies, will benefit from the CDware capability of reaching tens of thousands of potential customers with information, links to your web site, or directly with YOUR product!
<p><app class=ImageTape width=596 height=65 img_dir=../../../DEV/logos speed=10 dir=-10
url1=oracle
url2=progress
url3=gupta
url4=informix
url5=lotus
url6=ingres
>
</b>
<h5><p><A HREF=file:///tmp/httpd/.products/CDware/Help/SMICopyright.html>Copyright</A> 1995 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043 USA.  All rights reserved.</h5><br></pre>
<a href=file:///tmp/httpd/.products/DEV/credits.html>Credits</a>
</b>
</form>
</body>
</html>
.

format INDEX_DEFAULT =
<html>
<title>CDware - @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< </title>
$Company
<body>
<h1>@*
$Company
</h1><p>@*
$Description
<h4>@*
$Product
"</h4>
<hr>
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$Company
<br>???? XXXXXXXXXXXXX XXXXXXXXX<br>
XXXXXXXXXXXX, XX 99999<br>
<h5>To contact our sales services or ask for more information:<A HREF="mailto:@*
$Email
">@*
$Email
</A></H5>
<h5>To visit our web site:<A HREF="http://@*
$WebSite
">@*
$WebSite
</A></H5>
<body><html>
.
